package exception;

import rdbms.ddl.Table;


public class InvalidFieldException extends Exception {
	private static final String MESSAGE_NO_SUCH_FIELD = "Field %s does not exist in table %s.";
	private static final String MESSAGE_ID_ALREADY_SET = "Error trying to set id = %1$d for Field %2$s, already has id %3$s.";
	private String message;
	
	private InvalidFieldException() {
		
	}
	
	public String getMessage(){
		return message;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -564741932511157177L;

	public static InvalidFieldException NoSuchField(String fieldName, Table table) {
		InvalidFieldException ex = new InvalidFieldException();
		ex.message = String.format(MESSAGE_NO_SUCH_FIELD, fieldName, table.getName());
		return ex;
	}
	
	public static InvalidFieldException IdAlreadySet(int newId, int oldId, String fieldName) {
		InvalidFieldException ex = new InvalidFieldException();
		ex.message = String.format(MESSAGE_ID_ALREADY_SET, newId, oldId, fieldName);
		return ex;
	}
	
	
	

}
